package com.ruoyi.hd.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hd.domain.HdCommodityTime;
import com.ruoyi.hd.service.IHdCommodityTimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品记录管理Controller
 * 
 * @author ruoyi
 * @date 2022-07-19
 */
@RestController
@RequestMapping("/hd/commodityTime")
public class HdCommodityTimeController extends BaseController
{
    @Autowired
    private IHdCommodityTimeService hdCommodityTimeService;

    /**
     * 查询商品记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('hd:commodityTime:list')")
    @GetMapping("/list")
    public TableDataInfo list(HdCommodityTime hdCommodityTime)
    {
        startPage();
        List<HdCommodityTime> list = hdCommodityTimeService.selectHdCommodityTimeList(hdCommodityTime);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('hd:commodityTime:list')")
    @GetMapping("/dateTimeList")
    public TableDataInfo dateTimeList(HdCommodityTime hdCommodityTime)
    {
//        startPage();
        List<HdCommodityTime> list = hdCommodityTimeService.selectHdCommodityTimeByDateTimeList(hdCommodityTime);
        return getDataTable(list);
    }



    /**
     * 导出商品记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('hd:commodityTime:export')")
    @Log(title = "商品记录管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HdCommodityTime hdCommodityTime)
    {
        List<HdCommodityTime> list = hdCommodityTimeService.selectHdCommodityTimeList(hdCommodityTime);
        ExcelUtil<HdCommodityTime> util = new ExcelUtil<HdCommodityTime>(HdCommodityTime.class);
        util.exportExcel(response, list, "商品记录管理数据");
    }

    /**
     * 获取商品记录管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hd:commodityTime:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hdCommodityTimeService.selectHdCommodityTimeById(id));
    }

    /**
     * 获取商品记录管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hd:commodityTime:query')")
    @GetMapping(value = "/list/{ids}")
    public AjaxResult getInfos(@PathVariable("ids") Long [] ids)
    {
        return AjaxResult.success(hdCommodityTimeService.selectHdCommodityTimeByIds(ids));
    }

    /**
     * 新增商品记录管理
     */
    @PreAuthorize("@ss.hasPermi('hd:commodityTime:add')")
    @Log(title = "商品记录管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HdCommodityTime hdCommodityTime)
    {
        return toAjax(hdCommodityTimeService.insertHdCommodityTime(hdCommodityTime));
    }

    /**
     * 修改商品记录管理
     */
    @PreAuthorize("@ss.hasPermi('hd:commodityTime:edit')")
    @Log(title = "商品记录管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HdCommodityTime hdCommodityTime)
    {
        return toAjax(hdCommodityTimeService.updateHdCommodityTime(hdCommodityTime));
    }

    /**
     * 删除商品记录管理
     */
    @PreAuthorize("@ss.hasPermi('hd:commodityTime:remove')")
    @Log(title = "商品记录管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hdCommodityTimeService.deleteHdCommodityTimeByIds(ids));
    }

}
